import React from 'react'
import '../css/millet.css'
// import EventEmitter from "../event"

// import { Link } from "react-router-dom";
import Addmillet from "./Addmillet"; //加入小米
import Companyprofile from "./Companyprofile";//公司简介
import contactus from "./contactus";//联系我们
import culture from "./culture";//小米文化
import Development from "./Development";//发展经历
import Investorrelations from "./Investorrelations";//投资者关系
import news from "./news";//小米新闻
import Managementteam from "./Managementteam";//管理团队

import {
    BrowserRouter, //路由模式 嵌套路由模式要跟随上级路由
    Switch, //排他路由
    Route, //路由对象 组件
    Link
} from 'react-router-dom'

class millet extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            messages: [],
            user: "",
            password: "",
            name: ""
        }
    }
    componentDidMount() {

        if (this.props.location.state) {
            this.setState({
                user: this.props.location.state.user,
                password: this.props.location.state.password
            })
        }
        // console.log(this.state.user);

    }

    render() {
        return (

            <BrowserRouter>
                <div className="box">

                    <header>
                        <ul>
                            <li>小米商城</li>
                            <li>MIUI</li>
                            <li>loT</li>
                            <li>云服务</li>
                            <li>天星数科</li>
                            <li>有品</li>
                            <li>小爱开放平台</li>
                            <li>企业团购</li>
                            <li>资质证照</li>
                            <li>协议规则</li>
                            <li>下载app</li>
                            <li>智能生活</li>
                            <li>Select Location</li>

                        </ul>
                        <ul>
                            <li onClick={() => {
                                this.props.history.push({
                                    pathname: "/login"
                                })
                            }}>登录</li>

                            <li onClick={() => {
                                this.props.history.push({
                                    pathname: "/register"
                                })
                            }}>注册</li>
                            <li>消息通知</li></ul>
                    </header>
                    <div className="header-nav">
                        <img className="img1" src="./img/logo.png" />
                        <ul>
                            <li>全部商品分类</li>
                            <li>小米手机</li>
                            <li>Redmi红米</li>
                            <li>电视</li>
                            <li>笔记本</li>
                            <li>家电</li>
                            <li>路由器</li>
                            <li>智能硬件</li>
                            <li>服务</li>
                            <li>社区</li>
                        </ul>
                        <span><input className="i1" /></span>

                    </div>
                    <div>首页/关于小米/{this.state.name}</div>
                    <div>
                        <span>{this.state.user}</span><br />
                        <span>{this.state.password}</span>
                    </div>
                    <footer className="below">
                        <ul className="u1">
                            <li><Link onClick={() => {
                                this.setState({
                                    name: "公司简介"
                                })
                            }} to="/" >公司简介</Link></li>
                            <li><Link to="/Managementteam" onClick={() => {
                                this.setState({
                                    name: "管理团队"
                                })
                            }}  >管理团队</Link></li>
                            <li><Link to="/culture" onClick={() => {
                                this.setState({
                                    name: "小米文化"
                                })
                            }}  >小米文化</Link></li>
                            <li><Link to="/Development" onClick={() => {
                                this.setState({
                                    name: "发展经历"
                                })
                            }}  >发展经历</Link></li>
                            <li><Link to="/news" onClick={() => {
                                this.setState({
                                    name: "小米新闻"
                                })
                            }}  >小米新闻</Link></li>
                            <li><Link to="/Addmillet" onClick={() => {
                                this.setState({
                                    name: "加入小米"
                                })
                            }} >加入小米</Link></li>
                            <li><Link to="/Investorrelations" onClick={() => {
                                this.setState({
                                    name: "投资者关系"
                                })
                            }} >投资者关系</Link></li>
                            <li><Link to="/contactus" onClick={() => {
                                this.setState({
                                    name: "联系我们"
                                })
                            }} >联系我们</Link></li>

                        </ul>
                    </footer>
                    <div className="dv1">

                        <Switch>
                            <Route path="/Addmillet" component={Addmillet} />
                            <Route path="/contactus" component={contactus} />
                            <Route path="/culture" component={culture} />
                            <Route path="/Development" component={Development} />
                            <Route path="/Investorrelations" component={Investorrelations} />
                            <Route path="/news" component={news} />
                            <Route path="/Managementteam" component={Managementteam} />
                            <Route path="/" component={Companyprofile} />
                        </Switch>

                    </div>
                </div >
            </BrowserRouter>
        )
    }
}

export default millet;